home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / optivc16 / vbistd.h < prev    next >
C/C++ Source or Header  |  1999-03-06  |  6KB  |  158 lines

  1. /*  VBIstd.h
  2.  
  3.   vector management functions for byte-size integers.
  4.  
  5.   Copyright (c) by Martin Sander 1996-1999
  6.   All Rights Reserved.
  7. */
  8.  
  9. #ifndef __VBISTD_H
  10. #define __VBISTD_H
  11.  
  12. #if !defined( __VECLIB_H )
  13.    #include <VecLib.h>
  14. #endif
  15.  
  16. #ifdef __cplusplus
  17.    extern "C" {
  18. #endif
  19.  
  20. /*************************  Generation ***************************/
  21.  
  22. biVector  __vf  VBI_vector( ui size );
  23. biVector  __vf  VBI_vector0( ui size );
  24.  
  25.  
  26. /***************  Addressing single vector elements ******************/
  27.  
  28. char _VFAR * VBI_Pelement( biVector X, ui n );
  29.       /* returns a pointer to the n'th element of X. For the memory model
  30.          HUGE, the pointer is normalized. */
  31. #define VBI_element( X, n )  (*VBI_Pelement( X, n ))
  32.  
  33. /****************** Initialization  ******************************/
  34.  
  35. void  __vf  VBI_equ0( biVector X, ui size );
  36. void  __vf  VBI_equC( biVector X, ui size, char C );
  37. void  __vf  VBI_equV( biVector Y, biVector X, ui size );
  38. void  __vf  VBI_ramp( biVector X, ui size, char Start, char Rise );
  39. long  __vf  VBI_random( biVector X, ui size, long seed,
  40.                         char MinVal, char MaxVal );  /*  returns new seed */
  41.  
  42.  
  43. /************** Data-type interconversions  ****************************/
  44.  
  45. void  __vf  V_BItoUB( ubVector Y, biVector X, ui size ); /* signed-unsigned */
  46. void  __vf  V_UBtoBI( biVector Y, ubVector X, ui size );
  47.  
  48. void  __vf  V_BItoI(  iVector  Y, biVector X, ui size );  /* up-conversion */
  49. void  __vf  V_BItoSI( siVector Y, biVector X, ui size );
  50. void  __vf  V_BItoLI( liVector Y, biVector X, ui size );
  51. void  __vf  V_BItoQI( qiVector Y, biVector X, ui size );
  52.  
  53. void  __vf   V_SItoBI( biVector Y, siVector  X, ui size );/* down-conversion */
  54. void  __vf   V_ItoBI(  biVector Y, iVector  X, ui size );
  55. void  __vf   V_LItoBI( biVector Y, liVector X, ui size );
  56. void  __vf   V_QItoBI( biVector Y, qiVector X, ui size );
  57.  
  58. void  __vf   V_BItoF(  fVector Y, biVector X, ui size );
  59. void  __vf   V_BItoD(  dVector Y, biVector X, ui size );
  60. #ifdef __BORLANDC__
  61.     void  __vf   V_BItoE(  eVector Y, biVector X, ui size );
  62. #else  /* no 80-bit IEEE reals with Visual C++ and Optima++ */
  63.     #define V_BItoE V_BItoD
  64. #endif
  65.  
  66. /************** Index-oriented manipulations ***************************/
  67.  
  68. void  __vf  VBI_rev( biVector Y, biVector X, ui size );
  69. #ifdef V_HUGE
  70.     void  __vf  VBI_rotate( biVector Y, biVector X, ui size, long pos );
  71. #else
  72.     void  __vf  VBI_rotate( biVector Y, biVector X, ui size, int pos );
  73. #endif
  74.  
  75. void  __vf  VBI_delete( biVector X, ui size, ui pos );
  76. void  __vf  VBI_insert( biVector X, ui size, ui pos, char C );
  77.  
  78. void  __vf  VBI_sort( biVector Y, biVector X, ui size, int dir );
  79. void  __vf  VBI_sortind( uiVector Ind, biVector X, ui size, int dir );
  80.  
  81. void  __vf  VBI_subvector( biVector Y, ui sizey, biVector X, int samp );
  82. void  __vf  VBI_subvector_equC( biVector Y, ui subsz, unsigned samp, char C );
  83. void  __vf  VBI_subvector_equV( biVector Y, ui subsz, unsigned samp,
  84.                                 biVector X );
  85.  
  86. void  __vf  VBI_indpick( biVector Y, uiVector Ind, ui sizey, biVector X );
  87. void  __vf  VBI_indput(  biVector Y, biVector X, uiVector Ind, ui sizex );
  88.  
  89. ui    __vf  VBI_searchC( biVector XTab, ui size, char C, int mode );
  90. void  __vf  VBI_searchV( uiVector Ind, biVector X, ui sizex,
  91.                          biVector Tab, ui sizetab, int mode );
  92.  
  93. /********************   One-dimensional Vector Operations  ********/
  94.  
  95. char  __vf  VBI_sum( biVector X, ui size );
  96. void  __vf  VBI_runsum( biVector Y, biVector X, ui size );
  97. char  __vf  VBI_max( biVector X, ui size );
  98. char  __vf  VBI_min( biVector X, ui size );
  99. char  __vf  VBI_maxind( ui _VFAR *Ind, biVector X, ui size );
  100. char  __vf  VBI_minind( ui _VFAR *Ind, biVector X, ui size );
  101. void   __vf  VBI_runmax( biVector Y, biVector X, ui size );
  102. void   __vf  VBI_runmin( biVector Y, biVector X, ui size );
  103. double __vf  VBI_mean( biVector X, ui size );
  104.  
  105. int    __vf  VBI_iselementC( biVector Tab, ui size, char C );
  106. ui     __vf  VBI_iselementV( biVector Y, biVector X, ui sizex,
  107.                              biVector Tab, ui sizetab );
  108.  
  109.  
  110. /************************ Input / Output ******************************/
  111.  
  112. void  __vf   V_ifprint(  FILE _VFAR *stream, void _VFAR *X, ui size,
  113.                   unsigned nperline, unsigned linewidth, unsigned vers );
  114. #define VBI_fprint( st, x, sz, npl, lw ) \
  115.              V_ifprint(  st, (void _VFAR *)(x), sz, npl, lw, 0 )
  116.  
  117. #if !defined _Windows || defined __FLAT__ || defined _WIN32
  118.     void __vf  V_icprint(  void _VFAR *X, ui size, unsigned nperline, unsigned vers );
  119.     #define VBI_cprint( x, sz, npl ) V_icprint( (void _VFAR *) (x), sz, npl, 0 )
  120. #endif
  121. #define VBI_print(  x, sz, npl ) \
  122.              V_ifprint(  stdout, (void _VFAR *)(x), sz, npl, 80, 0 )
  123.  
  124. void  __vf   V_setRadix( int radix );
  125.            /* radix to be assumed by all whole-number read functions V??_read */
  126. void  __vf   VBI_read( biVector X, ui size, FILE _VFAR *stream );
  127. void  __vf   VBI_write( FILE _VFAR *stream, biVector X, ui size );
  128. void  __vf   VBI_nread( unsigned n, ui size, FILE _VFAR *stream, ... );
  129. void  __vf   VBI_nwrite( FILE _VFAR *stream, unsigned n, ui size, ... );
  130. void  __vf   VBI_setWriteFormat( char _VFAR *FormatString );
  131.         /* for VBI_write and VBI_nwrite. The format must be a format for short int ! */
  132. void  __vf   VBI_setWriteSeparate( char _VFAR *SepString ); /* for VBI_write */
  133. void  __vf   VBI_setNWriteSeparate( char _VFAR *SepString ); /* for VBI_nwrite */
  134. #ifdef V_HUGE
  135.     void  __vf   VBI_store(  FILE _VFAR *stream, biVector X, ui size );
  136.     void  __vf   VBI_recall( biVector X, ui size, FILE _VFAR *stream );
  137. #else
  138.     #ifdef __cplusplus
  139.          void  inline VBI_store( FILE _VFAR *stream, biVector X, ui size )
  140.          {    fwrite( X, sizeof(char), size, stream );
  141.          }
  142.          void  inline VBI_recall( biVector X, ui size, FILE _VFAR *stream )
  143.          {    fread(  X, sizeof(char), size, stream );
  144.          }
  145.     #else
  146.         #define VBI_store( str, X, sz )  \
  147.                      fwrite( X, sizeof(char), sz, str )
  148.         #define VBI_recall( X, sz, str ) \
  149.                      fread(  X, sizeof(char), sz, str )
  150.     #endif
  151. #endif      /* VBI_store, VBI_recall in binary format */
  152.  
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156.  
  157. #endif   /*  __VBISTD_H    */
  158.